clear
set more off

*requires estout, spineplot, cibar, tostregress
*ssc install estout
*ssc install spineplot
*ssc install cibar
*ssc install tostregress

cd ""

use "master-for-replication.dta", clear

svyset [pweight=weight]

/*Figure 5*/

svy,subpop(if nopulse==0): tab totalfcbinary_snopes totalfakebinary_grinberg, format(%9.5f)

preserve

clear
set obs 1
generate var1 = 0 in 1
set obs 2
replace var1 = 0 in 2
set obs 3
replace var1 = 1 in 3
set obs 4
replace var1 = 1 in 4
generate var2 = 0 in 1
replace var2 = 1 in 2
replace var2 = 0 in 3
replace var2 = 1 in 4
generate var3 = .490 in 1
replace var3 = .257 in 2
replace var3 = .067 in 3
replace var3 = .186 in 4
replace var3=var3*10000
expand var3
rename var1 fc
rename var2 fn
gen n=1
bysort fc fn: egen freq=sum(n)
gen freq2=freq/10000
format freq2 %9.3f
gen freqpct = string(100 * freq2, "%8.1f") + "%"
gen fc2=abs(fc-1)
spineplot fc2 fn,scheme(s2mono) bar1(color(gs14)) bar2(color(gs10)) graphregion(fcolor(white) ifcolor(none) style(none) color(gs16)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) xtitle("") xla(none,axis(2)) yla(none,axis(1)) yla(none,axis(2)) ytitle("",axis(1)) ytitle("",axis(2)) xtitle("",axis(1)) xtitle("",axis(2)) text(freqpct, mlabsize(*1.4)) xla(0.2935 `" "No untrustworthy"  "website exposure" "' 0.7935 `" "Untrustworthy"  "website exposure" "',axis(1) noticks) yla(0.54 `" "No fact-check"  "exposure" "' .055 `" "Fact-check"  "exposure" "',axis(2) noticks) legend(off) 
graph export "spineplot-grinberg.pdf", replace

restore

*Figure S7

label def tslab 0 "Clinton supporters" 1 "Trump supporters"
label val trumpsupport tslab

cibar totalfcbinary_snopes if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(trumpsupport) bargap(8) gap(35) graphopts(graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) region(lpattern(solid) lcolor(black)))  ytitle("") scheme(lean1) ylab(0 "0%" .2 "20%" .4 "40%" .60 "60%" .80 "80%",angle(0) grid) yscale(r(0 .81)))

cibar totalfcbinary_snopes_mobile if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(trumpsupport) bargap(8) gap(35) graphopts(graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) region(lpattern(solid) lcolor(black)))  ytitle("") scheme(lean1) ylab(0 "0%" .2 "20%" .4 "40%" .60 "60%" .80 "80%",angle(0) grid) yscale(r(0 .81)))

cibar totalfakebinary_grinberg if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(trumpsupport) bargap(8) gap(35) graphopts(graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) region(lpattern(solid) lcolor(black)))  ytitle("") scheme(lean1) ylab(0 "0%" .2 "20%" .4 "40%" .60 "60%" .80 "80%",angle(0) grid) yscale(r(0 .81)))

cibar totalfakebinary_grinberg_mobile if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(trumpsupport) bargap(8) gap(35) graphopts(graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) region(lpattern(solid) lcolor(black)))  ytitle("") scheme(lean1) ylab(0 "0%" .2 "20%" .4 "40%" .60 "60%" .80 "80%",angle(0) grid) yscale(r(0 .81)))

*Table 1

gen proTfrac_grin_domain=totalconfncount/totalnewsfncount_grinberg
gen proCfrac_grin_domain=totallibfncount/totalnewsfncount_grinberg

svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totalconfnbinary trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store A
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totallibfnbinary trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store B
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proTfrac_grin_domain trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store C
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proCfrac_grin_domain trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store D

estout A C B D, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Table S6

svy: reg totalconfnbinary trumpsupport clintonsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store A
svy: reg totallibfnbinary trumpsupport clintonsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store B
svy: reg proTfrac_grin_domain trumpsupport clintonsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store C
svy: reg proCfrac_grin_domain trumpsupport clintonsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store D

estout A C B D, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Table S3

svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totalconfnbinary_br trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store A
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totallibfnbinary trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store B

gen proTfrac_grin_domain_br=totalconfncount_br/totalnewsfncount_grinberg_br

svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proTfrac_grin_domain_br trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store C
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proCfrac_grin_domain trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store D

estout A C B D, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Table S2

svy,subpop(if clintonsupport==1 | trumpsupport==1): probit totalconfnbinary trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store A
svy,subpop(if clintonsupport==1 | trumpsupport==1): probit totallibfnbinary trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store B

estout A B, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Table S4

gen proCfrac_grin_URL=totallibfncount_url/totalnewsfncount_grinberg_url
gen proTfrac_grin_URL=totalconfncount_url/totalnewsfncount_grinberg_url

svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totalconfnbinary_url trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store A
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proTfrac_grin_URL trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store C

estout A C, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Table S7

gen crt2=crt
replace crt2=2 if crt2==3

svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totalconfnbinary trumpsupport##crt2 knowledge polinterest college female nonwhite age3044 age4559 age60plus
lincom 1.crt2 
lincom 2.crt2 
lincom 1.crt2+1.trumpsupport#1.crt2 
lincom 2.crt2+1.trumpsupport#2.crt2 
lincom (2.crt2+1.trumpsupport#2.crt2)-(1.crt2+1.trumpsupport#1.crt2) 
est store A
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totallibfnbinary trumpsupport##crt2 knowledge polinterest college female nonwhite age3044 age4559 age60plus i.crt2 
lincom 1.crt2 
lincom 2.crt2 
lincom 1.crt2+1.trumpsupport#1.crt2 
lincom 2.crt2+1.trumpsupport#2.crt2 
lincom (2.crt2+1.trumpsupport#2.crt2)-(1.crt2+1.trumpsupport#1.crt2) 
est store B
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proTfrac_grin_domain trumpsupport##crt2 knowledge polinterest college female nonwhite age3044 age4559 age60plus i.crt2
lincom 1.crt2
lincom 2.crt2
lincom 1.crt2+1.trumpsupport#1.crt2 
lincom 2.crt2+1.trumpsupport#2.crt2 
lincom (2.crt2+1.trumpsupport#2.crt2)-(1.crt2+1.trumpsupport#1.crt2) 
est store C
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proCfrac_grin_domain trumpsupport##crt2 knowledge polinterest college female nonwhite age3044 age4559 age60plus i.crt2
lincom 1.crt2 
lincom 2.crt2 
lincom 1.crt2+1.trumpsupport#1.crt2 
lincom 2.crt2+1.trumpsupport#2.crt2 
lincom (2.crt2+1.trumpsupport#2.crt2)-(1.crt2+1.trumpsupport#1.crt2) 
est store D

estout A C B D, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Figure S4

cibar totallibfnbinary if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(crt2) over2(trumpsupport) graphopts(scheme(lean2) ylab(0 "0%" .2 "20%" .4 "40%" .6 "60%" .8 "80%",angle(0) grid glcolor(gs3)) yscale(r(-.004 .81)) ytitle("") graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) region(lpattern(solid) lcolor(black)))) 

cibar proCfrac_grin_domain if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(crt2) over2(trumpsupport) graphopts(scheme(lean2) ytitle("") graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) region(lpattern(solid) lcolor(black))) ylab(0 "0%" .2 "20%" .4 "40%" .6 "60%" .8 "80%",angle(0) grid glcolor(gs3)) yscale(r(-.004 .81)))

*Table S9

gen fbterc=.
replace fbterc=1 if fbuse<2
replace fbterc=2 if fbuse==2
replace fbterc=3 if fbuse==3

gen fbterc2=(fbterc==2) if fbuse!=.
gen fbterc3=(fbterc==3) if fbuse!=.

gen trumpsupportXfb2=trumpsupport*fbterc2
gen trumpsupportXfb3=trumpsupport*fbterc3

svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totalconfnbinary trumpsupport fbterc2 fbterc3 trumpsupportXfb2 trumpsupportXfb3 polinterest college female nonwhite age3044 age4559 age60plus 
est store A
lincom trumpsupport+trumpsupportXfb2
lincom trumpsupport+trumpsupportXfb3 
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totallibfnbinary trumpsupport fbterc2 fbterc3 trumpsupportXfb2 trumpsupportXfb3 polinterest college female nonwhite age3044 age4559 age60plus 
est store B
lincom trumpsupport+trumpsupportXfb2
lincom trumpsupport+trumpsupportXfb3 
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proTfrac_grin_domain trumpsupport fbterc2 fbterc3 trumpsupportXfb2 trumpsupportXfb3 polinterest college female nonwhite age3044 age4559 age60plus 
est store C
lincom trumpsupport+trumpsupportXfb2
lincom trumpsupport+trumpsupportXfb3 
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proCfrac_grin_domain trumpsupport fbterc2 fbterc3 trumpsupportXfb2 trumpsupportXfb3 polinterest college female nonwhite age3044 age4559 age60plus 
est store D
lincom trumpsupport+trumpsupportXfb2
lincom trumpsupport+trumpsupportXfb3 

estout A C B D, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Figure S5

label def fblab 1 "Low" 2 "Medium" 3 "High"
label val fbterc fblab

cibar totalconfnbinary if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(fbterc) over2(trumpsupport) bargap(8) gap(35) graphopts(graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) region(lpattern(solid) lcolor(black)))  ytitle("") scheme(lean1) ylab(0 "0%" .2 "20%" .4 "40%" .60 "60%" .80 "80%",angle(0) grid) yscale(r(0 .81)))

cibar totallibfnbinary if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(fbterc) over2(trumpsupport) bargap(8) gap(35) graphopts(graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) region(lpattern(solid) lcolor(black)))  ytitle("") scheme(lean1) ylab(0 "0%" .2 "20%" .4 "40%" .60 "60%" .80 "80%",angle(0) grid) yscale(r(0 .81)))

*Table S5

svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totalprotrumpfnbinary trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store A
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totalproclintonfnbinary trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store B
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proTfrac trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store C
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proCfrac trumpsupport knowledge polinterest college female nonwhite age3044 age4559 age60plus 
est store D

estout A C B D, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Table S11

xtile newsterc=totalnewscount_grinberg,nq(3)
tab newsterc

gen newsterc2=(newsterc==2) if totalnewscount_grinberg!=.
gen newsterc3=(newsterc==3) if totalnewscount_grinberg!=.

gen trumpsupportXnews2=trumpsupport*newsterc2
gen trumpsupportXnews3=trumpsupport*newsterc3

svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totalconfnbinary trumpsupport newsterc2 newsterc3 trumpsupportXnews2 trumpsupportXnews3 polinterest college female nonwhite age3044 age4559 age60plus 
est store A
lincom trumpsupport+trumpsupportXnews2
lincom trumpsupport+trumpsupportXnews3 
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg totallibfnbinary trumpsupport newsterc2 newsterc3 trumpsupportXnews2 trumpsupportXnews3 polinterest college female nonwhite age3044 age4559 age60plus 
est store B
lincom trumpsupport+trumpsupportXnews2
lincom trumpsupport+trumpsupportXnews3 
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proTfrac_grin_domain trumpsupport newsterc2 newsterc3 trumpsupportXnews2 trumpsupportXnews3 polinterest college female nonwhite age3044 age4559 age60plus 
est store C
lincom trumpsupport+trumpsupportXnews2
lincom trumpsupport+trumpsupportXnews3 
svy,subpop(if clintonsupport==1 | trumpsupport==1): reg proCfrac_grin_domain trumpsupport newsterc2 newsterc3 trumpsupportXnews2 trumpsupportXnews3 polinterest college female nonwhite age3044 age4559 age60plus 
est store D
lincom trumpsupport+trumpsupportXnews2
lincom trumpsupport+trumpsupportXnews3 

estout A C B D, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Figure S9

label def newsdef 1 "Low news consumer" 2 "Medium news consumer" 3 "High news consumer"
label val newsterc newsdef

cibar totalconfnbinary if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(newsterc) over2(trumpsupport) bargap(8) gap(35) graphopts(graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) size(*.8) region(lpattern(solid) lcolor(black)))  ytitle("") scheme(lean1) ylab(0 "0%" .2 "20%" .4 "40%" .60 "60%" .80 "80%" 1 "100%",angle(0) grid) yscale(r(0 1.01)))

cibar totallibfnbinary if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(newsterc) over2(trumpsupport) bargap(8) gap(35) graphopts(graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) size(*.8) region(lpattern(solid) lcolor(black)))  ytitle("") scheme(lean1) ylab(0 "0%" .2 "20%" .4 "40%" .60 "60%" .80 "80%" 1 "100%",angle(0) grid) yscale(r(0 1.01)))

*Table S10

xtile knowterc=knowledge,nq(3)
tab knowterc

gen trumpsupportXkt2=trumpsupport*(knowterc==2)
gen trumpsupportXkt3=trumpsupport*(knowterc==3)

gen knowterc2=(knowterc==2)
gen knowterc3=(knowterc==3)

svy,subpop(if clintonsupport==1 | trumpsupport==1):  reg totalconfnbinary trumpsupport knowterc2 knowterc3 trumpsupportXkt2 trumpsupportXkt3 polinterest college female nonwhite age3044 age4559 age60plus 
est store A
lincom trumpsupport+trumpsupportXkt2
lincom trumpsupport+trumpsupportXkt3
svy,subpop(if clintonsupport==1 | trumpsupport==1):  reg totallibfnbinary trumpsupport knowterc2 knowterc3 trumpsupportXkt2 trumpsupportXkt3 polinterest college female nonwhite age3044 age4559 age60plus 
est store B
lincom trumpsupport+trumpsupportXkt2
lincom trumpsupport+trumpsupportXkt3
svy,subpop(if clintonsupport==1 | trumpsupport==1):  reg proTfrac_grin_domain trumpsupport knowterc2 knowterc3 trumpsupportXkt2 trumpsupportXkt3 polinterest college female nonwhite age3044 age4559 age60plus
est store C
lincom trumpsupport+trumpsupportXkt2
lincom trumpsupport+trumpsupportXkt3
svy,subpop(if clintonsupport==1 | trumpsupport==1):  reg proCfrac_grin_domain trumpsupport knowterc2 knowterc3 trumpsupportXkt2 trumpsupportXkt3 polinterest college female nonwhite age3044 age4559 age60plus 
est store D
lincom trumpsupport+trumpsupportXkt2
lincom trumpsupport+trumpsupportXkt3 

estout A C B D, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Figure S8

label def knowlab 1 "Low knowledge" 2 "Medium knowledge" 3 "High knowledge"
label val knowterc knowlab

cibar totalconfnbinary if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(knowterc) over2(trumpsupport) bargap(8) gap(35) graphopts(graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) region(lpattern(solid) lcolor(black)))  ytitle("") scheme(lean1) ylab(0 "0%" .2 "20%" .4 "40%" .60 "60%" .80 "80%",angle(0) grid) yscale(r(0 .81)))

cibar totallibfnbinary if (clintonsupport==1 | trumpsupport==1) [pweight=weight], over1(knowterc) over2(trumpsupport) bargap(8) gap(35) graphopts(graphregion(fcolor(white) ifcolor(none)) plotregion(fcolor(none) lcolor(white) ifcolor(none) ilcolor(none)) legend(row(1) pos(6) region(lpattern(solid) lcolor(black)))  ytitle("") scheme(lean1) ylab(0 "0%" .2 "20%" .4 "40%" .60 "60%" .80 "80%",angle(0) grid) yscale(r(0 .81)))

*Table S8

svy: reg totalconfnbinary i.decile polinterest college female nonwhite age3044 age4559 age60plus
est store A
svy: reg totallibfnbinary i.decile polinterest college female nonwhite age3044 age4559 age60plus 
est store B
svy: reg proTfrac_grin_domain i.decile polinterest college female nonwhite age3044 age4559 age60plus 
est store C
svy: reg proCfrac_grin_domain i.decile polinterest college female nonwhite age3044 age4559 age60plus 
est store D

estout A C B D, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Table 2/S13

gen presvote5=.
replace presvote5=0 if presvote16>2 & presvote16<6 /*probably won't vote, somebody else, don't know*/
replace presvote5=1 if presvote16==1 /*clinton*/
replace presvote5=2 if presvote16==2 /*trump*/
replace presvote5=3 if presvote16==16 /*johnson*/
replace presvote5=4 if presvote16==17 /*stein*/

gen presvote3=presvote5
recode presvote3 (3=0)(4=0)

replace decile_pre="" if decile_pre=="NA"
destring decile_pre, replace

gen decilegroup=.
replace decilegroup=0 if decile_pre<4
replace decilegroup=1 if decile_pre>3 & decile_pre<8
replace decilegroup=2 if decile_pre>7 & decile_pre!=.

replace totalconfnbinary_pre="" if totalconfnbinary_pre=="NA"
destring totalconfnbinary_pre, replace

foreach var of varlist tsmart_P2012 tsmart_G2012 tsmart_P2016 tsmart_G2016 {
replace `var'=0 if `var'==.
}

svy: reg trumpsupport i.presvote3 i.ib0.totalconfnbinary_pre ib1.decilegroup knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store G

tostregress trumpsupport i.presvote3 i.ib0.totalconfnbinary_pre ib1.decilegroup knowledge polinterest college female nonwhite age3044 age4559 age60plus, eqvt(delta) eqvl(.09) rel svy()

tostregress trumpsupport i.presvote3 i.ib0.totalconfnbinary_pre ib1.decilegroup knowledge polinterest college female nonwhite age3044 age4559 age60plus, eqvt(delta) eqvl(.1) rel svy()

svy: reg tsmart_G2016 i.presvote3 ib0.totalconfnbinary_pre ib1.decilegroup tsmart_P2012 tsmart_G2012 tsmart_P2016 knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store I

tostregress tsmart_G2016 i.presvote3 ib0.totalconfnbinary_pre ib1.decilegroup tsmart_P2012 tsmart_G2012 tsmart_P2016 knowledge polinterest college female nonwhite age3044 age4559 age60plus, eqvt(delta) eqvl(.09) rel svy()

tostregress tsmart_G2016 i.presvote3 ib0.totalconfnbinary_pre ib1.decilegroup tsmart_P2012 tsmart_G2012 tsmart_P2016 knowledge polinterest college female nonwhite age3044 age4559 age60plus, eqvt(delta) eqvl(.1) rel svy()

estout G I, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Table S14

svy,subpop(if presvote3==1): reg trumpsupport ib0.totalconfnbinary_pre ib1.decilegroup knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store Ga

tostregress trumpsupport ib0.totalconfnbinary_pre ib1.decilegroup knowledge polinterest college female nonwhite age3044 age4559 age60plus, eqvt(delta) eqvl(.17) rel svy(subpop(if presvote3==1))

svy,subpop(if presvote3==2): reg trumpsupport ib0.totalconfnbinary_pre ib1.decilegroup knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store Gb

tostregress trumpsupport ib0.totalconfnbinary_pre ib1.decilegroup knowledge polinterest college female nonwhite age3044 age4559 age60plus, eqvt(delta) eqvl(.07) rel svy(subpop(if presvote3==2))

svy,subpop(if presvote3==0): reg trumpsupport ib0.totalconfnbinary_pre ib1.decilegroup knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store Gc

tostregress trumpsupport ib0.totalconfnbinary_pre ib1.decilegroup knowledge polinterest college female nonwhite age3044 age4559 age60plus, eqvt(delta) eqvl(.13) rel svy(subpop(if presvote3==0))

estout Ga Gb Gc, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Table S15

svy,subpop(if presvote3==1): reg tsmart_G2016 ib0.totalconfnbinary_pre ib1.decilegroup tsmart_P2012 tsmart_G2012 tsmart_P2016 knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store Ia

tostregress tsmart_G2016 ib0.totalconfnbinary_pre ib1.decilegroup tsmart_P2012 tsmart_G2012 tsmart_P2016 knowledge polinterest college female nonwhite age3044 age4559 age60plus, eqvt(delta) eqvl(.16) rel svy(subpop(if presvote3==1))

svy,subpop(if presvote3==2): reg tsmart_G2016 ib0.totalconfnbinary_pre ib1.decilegroup tsmart_P2012 tsmart_G2012 tsmart_P2016 knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store Ib

tostregress tsmart_G2016 ib0.totalconfnbinary_pre ib1.decilegroup tsmart_P2012 tsmart_G2012 tsmart_P2016 knowledge polinterest college female nonwhite age3044 age4559 age60plus, eqvt(delta) eqvl(.10) rel svy(subpop(if presvote3==2))

svy,subpop(if presvote3==0): reg tsmart_G2016 ib0.totalconfnbinary_pre ib1.decilegroup tsmart_P2012 tsmart_G2012 tsmart_P2016 knowledge polinterest college female nonwhite age3044 age4559 age60plus
est store Ic

tostregress tsmart_G2016 ib0.totalconfnbinary_pre ib1.decilegroup tsmart_P2012 tsmart_G2012 tsmart_P2016 knowledge polinterest college female nonwhite age3044 age4559 age60plus, eqvt(delta) eqvl(.13) rel svy(subpop(if presvote3==0))

estout Ia Ib Ic, replace varwidth(25) cells((b(fmt(%9.2f)) se(fmt(%9.2f)) p(fmt(%9.2f)) ci(fmt(%9.2f) par("" ", " "")))) stats(r2 N, fmt(%9.2f %9.0f) labels("R^2" "N")) style(tex) nobaselevels

*Table 3 (omits ANES data)

gen agecat=1 if ageunder30==1
replace agecat=2 if age3044==1
replace agecat=3 if age4559==1
replace agecat=4 if age60plus==1

svy: tab voteNovember
svy,subpop(if nopulse==0): tab voteNovember
svy,subpop(if nomobilepulse==0): tab voteNovember

svy: tab agecat
svy,subpop(if nopulse==0): tab agecat
svy,subpop(if nomobilepulse==0): tab agecat

svy: tab female
svy,subpop(if nopulse==0): tab female
svy,subpop(if nomobilepulse==0): tab female

svy: tab race
svy,subpop(if nopulse==0): tab race
svy,subpop(if nomobilepulse==0): tab race
